function t(t) {
    if (Array.isArray(t)) {
        for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];
        return e;
    }
    return Array.from(t);
}

function a(t, a, e) {
    return a in t ? Object.defineProperty(t, a, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[a] = e, t;
}

var e;

Page({
    data: (e = {
        index: 0,
        more_list: !1,
        share: 0,
        id: null,
        user_id: null,
        page_loading: !0,
        _num: 1,
        page: 1,
        keyword: "",
        list: [],
        toSearch: !1,
        to_destroy: !1
    }, a(e, "id", null), a(e, "status", null), a(e, "type", 1), a(e, "to_handle", !1), 
    a(e, "dialog", !1), a(e, "newStore", "0"), a(e, "total_money", null), a(e, "money", null), 
    a(e, "order_count", null), a(e, "card_count", null), a(e, "sort", null), a(e, "iphone_x", !1), 
    a(e, "actions", [ {
        name: "取消",
        color: "#666666"
    }, {
        name: "确认",
        color: "#446dfd",
        loading: !1
    } ]), e),
    shareSort: function(t) {
        var a = this, e = t.currentTarget.dataset.type;
        this.setData({
            list: []
        });
        var i = "", s = getApp().api.admin.user.user;
        2 == this.data._num ? (s = getApp().api.admin.user.share, i = 1) : 3 == this.data._num && (s = getApp().api.admin.user.clerk), 
        1 == e ? (i = 1, 1 == this.data.total_money ? this.setData({
            total_money: 2,
            sort: 2
        }) : this.setData({
            total_money: 1,
            sort: 1
        })) : 2 == e ? (i = 1, 3 == this.data.money ? this.setData({
            money: 4,
            sort: 4
        }) : this.setData({
            money: 3,
            sort: 3
        })) : 3 == e ? 1 == this.data.order_count ? this.setData({
            order_count: 2,
            sort: 2
        }) : this.setData({
            order_count: 1,
            sort: 1
        }) : 4 == e ? 3 == this.data.total_money ? this.setData({
            total_money: 4,
            sort: 4
        }) : this.setData({
            total_money: 3,
            sort: 3
        }) : 5 == e && (5 == this.data.card_count ? this.setData({
            card_count: 6,
            sort: 6
        }) : this.setData({
            card_count: 5,
            sort: 5
        })), getApp().iView.$Toast({
            content: "加载中",
            type: "loading",
            duration: 0
        }), getApp().request({
            url: s,
            data: {
                page: 1,
                keyword: "",
                status: i,
                sort: this.data.sort
            },
            method: "get",
            success: function(t) {
              if (getApp().iView.$Toast.hide(), 0 == t.code) {
                var e = t.data.list, i = !1;
                if (10 == e.length && (i = !0), 3 == a.data._num) {
                  var s = t.data.store_list;
                  a.setData({
                    store_list: s
                  });
                }
                a.setData({
                  list: e,
                  more_list: i,
                  page: 2
                });
              } else getApp().core.showToast({
                title: t.data.msg,
                icon: 'none'
              });
            },
            fail: function(t) {
              getApp().core.showToast({
                title: t.data.msg,
                icon: 'none'
              });
            }
        });
    },
    search: function() {
        this.getList(1);
    },
    input: function(t) {
        this.setData({
            keyword: t.detail.value
        });
    },
    choose_type: function(t) {
        var a = t.currentTarget.dataset.type;
        this.setData({
            type: a
        });
    },
    cancel: function() {
        this.setData({
            to_handle: !1,
            keyword: "",
            type: 1
        });
    },
    submit: function() {
        var a = this, e = this, i = void 0, s = void 0;
        getApp().core.showLoading();
        1 == this.data.type ? (i = getApp().api.admin.user.integral, s = {
            user_id: this.data.id,
            num: this.data.keyword,
            type: this.data.status
        }) : 2 == this.data.type && (i = getApp().api.admin.user.balance, s = {
            user_id: this.data.id,
            price: this.data.keyword,
            type: this.data.status
        }), getApp().request({
            url: i,
            data: s,
            method: "post",
            success: function(i) {
              getApp().core.hideLoading(), 0 == i.code ? (getApp().core.showToast({
                title: "操作成功",
                icon: 'none'
              }), [].concat(t(a.data.actions))[1].loading = !1, e.setData({
                to_handle: !1,
                keyword: "",
                type: 1
              }), e.getList(1)) : getApp().core.showToast({
                title: i.msg,
                icon: 'none'
              });
            },
            fail: function(t) {
              getApp().core.showToast({
                title: t.msg,
                icon:'non'
              });
            }
        });
    },
    handle: function(t) {
        var a = t.currentTarget.dataset.status, e = t.currentTarget.dataset.id;
        this.setData({
            status: a,
            id: e,
            to_handle: !0
        });
    },
    beSearch: function() {
        var t = !this.data.toSearch;
        this.data.keyword.length > 0 && (t = this.data.toSearch), this.setData({
            toSearch: t
        });
    },
    tab: function(t) {
        var a = t.currentTarget.dataset.num;
        this.setData({
            _num: a,
            list: [],
            keyword: "",
            total_money: null,
            sort: "",
            toSearch: !1
        }), this.getList(1);
    },
    onLoad: function(t) {
        var a = t.share;
        this.setData({
            share: a
        }), getApp().device().indexOf("iphone_x") > -1 && this.setData({
            iphone_x: !0
        }), this.getList(this.data.page);
    },
    change: function(t) {
        var a = this, e = void 0, i = t.currentTarget.dataset.id, s = t.currentTarget.dataset.user, n = t.currentTarget.dataset.name;
        a.data.store_list.forEach(function(t, i) {
            n == a.data.store_list[i].name && (e = i);
        }), this.setData({
            dialog: !this.data.dialog,
            id: i,
            index: e,
            user_id: s
        });
    },
    bindChange: function(t) {
        var a = t.detail.value[0];
        this.setData({
            newStore: a
        });
    },
    toDestroy: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.user;
        this.setData({
            to_destroy: !0,
            id: a,
            user_id: e
        });
    },
    destroy: function(a) {
        var e = this, i = a.detail.index;
        0 === i ? this.setData({
            to_destroy: !1
        }) : 1 === i && ([].concat(t(this.data.actions))[1].loading = !0, getApp().request({
            url: getApp().api.admin.user.clerk_edit,
            data: {
                id: this.data.id,
                shop_id:0
            },
            method: "post",
            success: function(t) {
              getApp().core.hideLoading(), 0 == t.code ? (e.setData({
                to_destroy: !1
              }), e.getList(1)) : getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            },
            fail: function(t) {
              getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            }
        }));
    },
    toggle: function(t) {
        var a = this, e = t.currentTarget.dataset.status;
        getApp().core.showLoading()
        1 == e ? getApp().request({
            url: getApp().api.admin.user.clerk_edit,
            data: {
                user_id: this.data.user_id,
                id: this.data.id,
                shop_id: this.data.store_list[this.data.newStore].id
            },
            method: "post",
            success: function(t) {
              getApp().core.hideLoading(), 0 == t.code ? (a.setData({
                dialog: !a.data.dialog,
                newStore: "0"
              }), a.getList(1)) : getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            },
            fail: function(t) {
              getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            }
        }): 2 == e && this.setData({
            dialog: !this.data.dialog,
            newStore: "0"
        });
    },
    getList: function(t) {
        var a = this, e = void 0, i = "";
      1 == this.data._num ? e = getApp().api.admin.user.user : 2 == this.data._num ? (e = getApp().api.admin.user.share, 
        i = 1) : 3 == this.data._num && (e = getApp().api.admin.user.clerk), getApp().core.showLoading({
            content: "加载中",
        }), getApp().request({
            url: e,
            data: {
                page: t,
                status: i,
                keyword: this.data.keyword
            },
            method: "get",
            success: function(e) {
              getApp().core.hideLoading()
              if (0 == e.code) {
                var i = e.data.list, s = !1;
                if (20 == i.length && (s = !0), 3 == a.data._num) {
                  var n = e.data.store_list;
                  a.setData({
                    store_list: n
                  });
                }
                t++ , a.setData({
                  list: i,
                  more_list: s,
                  page: t
                });
              } else getApp().core.showToast({
                title: e.msg,
                icon: 'none'
              });
            },
            fail: function(t) {
              getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            }
        });
    },
    getMore: function(t) {
        var a = this, e = void 0, i = "";
        1 == this.data._num ? e = getApp().api.admin.user.user : 2 == this.data._num ? (e = getApp().api.admin.user.share, 
        i = 1) : 3 == this.data._num && (e = getApp().api.admin.user.clerk), getApp().core.showLoading({
            content: "加载中",
        }), getApp().request({
            url: e,
            data: {
                page: t,
                status: i,
                sort: this.data.sort,
                keyword: this.data.keyword
            },
            method: "get",
            success: function (e) {
              getApp().core.hideLoading()
              if (0 == e.code) {
                var i = a.data.list, s = e.data.list, n = !1;
                20 == s.length && (n = !0), i = i.concat(s), t++ , a.setData({
                  list: i,
                  more_list: n,
                  page: t
                });
              } else getApp().core.showToast({
                title: e.msg,
                icon:'none'
              });
            },
            fail: function (t) {
              getApp().core.showToast({
                title: t.msg,
                icon: 'none'
              });
            }
        })
    },
    onReady: function(t) {
        this.setData({
            page_loading: !1
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.more_list && this.getMore(this.data.page);
    },
    onShareAppMessage: function() {}
});